package com.bawei.image.loader

import android.content.Context
import android.net.Uri
import android.widget.ImageView
import com.bawei.image.IImageLoader
import com.bawei.image.ImageOptions
import java.io.File
import java.lang.ref.SoftReference

/**
 * Author: Jason Zhang
 * Date: 2024/9/12
 * Desc: 自定义图片加载器
 */
class CustomImageLoader: IImageLoader {
    override fun loadFileIntoImageView(context: Context, file: File, target: ImageView, options: ImageOptions) {
        loadImage(context, file, target, options)
    }

    override fun loadUrlIntoImageView(context: Context, url: String, target: ImageView, options: ImageOptions) {
        loadImage(context, url, target, options)
    }

    override fun loadResourceIntoImageView(context: Context, resource: Int, target: ImageView, options: ImageOptions) {
        loadImage(context, resource, target, options)
    }

    override fun loadByteArrayIntoImageView(context: Context, bytes: ByteArray, target: ImageView, options: ImageOptions) {
        loadImage(context, bytes, target, options)
    }

    override fun loadUriIntoImageView(context: Context, uri: Uri, target: ImageView, options: ImageOptions) {
        loadImage(context, uri, target, options)
    }


    private fun loadImage(context: Context, source: Any, target: ImageView, options: ImageOptions){
        var softRef = SoftReference(context)
        softRef.get()?.run {


        }
    }


}